<!DOCTYPE html>
<html>
<head>
	{include file="common_header" /}
	{include file="common_top" /}
</head>
<body>

  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-card-header">添加分站</div>
      <div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" action="" lay-filter="component-form-group">

          
          <div class="layui-form-item">
            <label class="layui-form-label">会员帐号</label>
            <div class="layui-input-block">
              <input type="text" name="phone" id="phone"   placeholder="所属会员帐号，请输入手机号" class="layui-input">
            </div>
          </div>

		  
		  <div class="layui-form-item">
            <label class="layui-form-label">站点名称</label>
            <div class="layui-input-block">
              <input type="text" name="title" id="title"   placeholder="站点名称" class="layui-input">
            </div>
          </div>
		  
		  <div class="layui-form-item">
            <label class="layui-form-label">站点域名</label>
            <div class="layui-input-block">
              <input type="text" name="domain" id="domain"   placeholder="站点域名" class="layui-input">
            </div>
          </div>
		  

          <div class="layui-form-item">
            <label class="layui-form-label">站点状态</label>
            <div class="layui-input-block">
              <input type="radio" name="status" value="1" title="启用" checked="">
              <input type="radio" name="status" value="2" title="禁用">
            </div>
          </div>       
          <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
              <div class="layui-footer" style="left: 0;">
                <div class="layui-btn sub">立即提交</div>
                <button type="reset" class="layui-btn layui-btn-primary ">重置</button>
              </div>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
{include file="common_footer" /} 
<script>

$(".sub").click(function(){
	//if(!$(".btn").hasClass("sub")){return false;}
	
	var phone        = $("#phone").val();
	var title        = $("#title").val();
	var domain      = $("#domain").val();
	var status       = $("input[name='status']:checked").val();
	
	if(phone == ""){
		show_error("会员帐号不能为空");
		return false
	}


	if(title == ""){
		show_error("站点名称不能为空");
		return false
	}
	
	$.ajax({
		type:"POST",
		url:"{:url('substation/add')}",
		dataType:"json",
		data:{
			phone:phone,
			title:title,
			status:status,
			domain:domain,
		},
		success:function(res){
			if(res.status == "success"){
				show_toast_callurl(res.data,"{:url('substation/index')}","success");
			}else{
				show_error(res.data);
			}
		},
		error:function(jqXHR){
			console.log("Error: "+jqXHR.status);
		},
	});
	
});
</script>
</body>
</html>
